/**
 * @param {number[][]} matrix
 * @return {void} Do not return anything, modify matrix in-place instead.
 */
var rotate = function (matrix) {
  //矩阵转置：j从i+1开始 是为了 防止重复交换 + 保持对角线元素不动
  for (let i = 0; i < matrix.length; i++) {
    for (let j = i + 1; j < matrix.length; j++) {
      [matrix[i][j], matrix[j][i]] = [matrix[j][i], matrix[i][j]]
    }
  }
  //反转每一行的元素
  for (let i = 0; i < matrix.length; i++) {
    matrix[i].reverse()
  }
  return matrix
};